home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / batch / magic / magic.doc next >
Encoding:
Text File  |  1987-08-23  |  10.5 KB  |  265 lines

  1. 
  2.  
  3.           magic
  4.           magic
  5.           magic                  DNS C Documentation               Page -1-
  6.  
  7.  
  8.           NAME
  9.           NAME
  10.           NAME
  11.  
  12.           magic special-characters-to-output
  13.           magic -get arguments
  14.           magic -detab[n] [infile [outfile]]
  15.  
  16.           DESCRIPTION
  17.           DESCRIPTION
  18.           DESCRIPTION
  19.  
  20.           magic
  21.           magic
  22.           magic  is a multipurpose utility for the IBM PC & compatibles. It
  23.           allows you to easily output "special"  character  stings  to  the
  24.           screen  (like  escape sequences), provides interactive batch file
  25.           input, and can detab (expand tabs  into  whitespace)  in  a  text
  26.           file.
  27.  
  28.           __________ _______ __________
  29.           Outputting Special Characters
  30.  
  31.                    magic
  32.                    magic
  33.           Program  magic  can be used to generate character sequences which
  34.                                                 magic
  35.                                                 magic
  36.           are normally hard to generate. Typing magic alone  shows  how  to
  37.           use  the program. The following special symbols are recognized by
  38.           magic
  39.           magic
  40.           magic. The curly braces are required.
  41.  
  42.                {ESC}           Writes the ESC character
  43.                {CR}            Writes a CRLF (Enter)
  44.                {TAB}           Writes a TAB
  45.                {FF}            Writes a form feed
  46.                {0xnn}          Writes hex number nn
  47.                ^S              Writes Ctrl-S
  48.  
  49.                     ___
  50.           Note that any character can be written with the {0xnn} mechanism,
  51.           and that a ^ (hat) immediately preceding a character  writes  the
  52.           control of that character.
  53.  
  54.           Our AUTOEXEC.BAT's have the following lines of code in them:
  55.  
  56.                magic {cr} | print /B:4096  > null
  57.                magic {ff} > lpt1
  58.                magic {esc}[2J{esc}[34;46m
  59.  
  60.                                                                    magic
  61.                                                                    magic
  62.           The  first example installs the DOS PRINT command, where magic is
  63.           used to write an Enter, which is piped into PRINT to  answer  the
  64.           question PRINT asks you.
  65.  
  66.           The  second example sends a form feed to our printer, ensuring it
  67.           is starting out on a fresh, unbent page.
  68.  
  69.           The third example shows how we can write some  ESC  sequences  to
  70.           the screen to clear the screen and set our screen colors.
  71.  
  72.           _ _____ ____ ________
  73.           A Batch File Enhancer
  74.  
  75.           magic
  76.           magic
  77.           magic  can  be  invoked  to  get responses from the user, and set
  78.           error return codes to indicate how the user responded.  Usage  is
  79.           as follows:
  80.  
  81.                magic -get arguments
  82.  
  83.  
  84.  
  85.                                                                       magic
  86.                                                                       magic
  87.                                    August 23, 1987                    magic
  88.  
  89.  
  90.  
  91.  
  92.           magic
  93.           magic
  94.           magic                  DNS C Documentation               Page -2-
  95.  
  96.  
  97.           Arguments are as follows:
  98.  
  99.                -beep
  100.                -prompt "Query for user"
  101.                -default=response
  102.                -timeout=nn
  103.                resp=errnum
  104.  
  105.                -beep                             magic
  106.                -beep                             magic
  107.           The  -beep  option beeps the user when magic is run, to encourage
  108.           the user to look at his screen.
  109.  
  110.               -default         -df
  111.               -default         -df
  112.           The -default option (-df for short) allows you  to  specify  what
  113.           the default response should be (if the user just hits Enter).
  114.  
  115.                -timeout           -to
  116.                -timeout           -to
  117.           The  -timeout  option  (-to  for  short)  allows you to specify a
  118.           number of seconds after which the default answer will be supplied
  119.                              ____
  120.           automatically. You must  supply  a  default  if  you  expect  the
  121.           timeout to work.
  122.  
  123.           resp                                                       errnum
  124.           resp                                                       errnum
  125.           resp  is  text which the user is expected to respond with. errnum
  126.           is a number, 0-255, which will be returned as an error code.  The
  127.           error code can be checked in a batch file easily.
  128.  
  129.           Here is a real example of usage:
  130.  
  131.                magic -get abc=1 def=2 ghi=3
  132.  
  133.           will  return  an  error  of 1 if the user types in abc, a 2 if he
  134.           types in def, etc. When typing  in  the  relationship  between  a
  135.           string and an error code, there can be no spaces.
  136.  
  137.           Here are some more complicated examples:
  138.  
  139.                magic -get -prompt "Format (y/n)? " -default=y  y=1 n=2
  140.                magic -get -default=abc -timeout=20 abc=1 def=2 ghi=3
  141.  
  142.                                   magic
  143.                                   magic
  144.           In  the  first example, magic detects that all possible responses
  145.           are a single character, and will not  require  the  user  to  hit
  146.           Enter (i.e. just hitting Y or N is enough).
  147.  
  148.                              -prompt         -pr
  149.                              -prompt         -pr
  150.           If  you  use  the  -prompt option (-pr for short), the next thing
  151.           following the -prompt is taken  to  be  the  prompt  to  display.
  152.           Surrounding the prompt string with quotes (as shown above) allows
  153.           you to have a multi word prompt.
  154.  
  155.                                              magic
  156.                                              magic
  157.           Here is a BAT file which shows how magic is used in real life:
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.                                                                       magic
  171.                                                                       magic
  172.                                    August 23, 1987                    magic
  173.  
  174.  
  175.  
  176.  
  177.           magic
  178.           magic
  179.           magic                  DNS C Documentation               Page -3-
  180.  
  181.  
  182.                echo off
  183.                echo Enter either abc, def, or ghi
  184.                magic -get -default=abc abc=1 def=2 ghi=3
  185.                rem = Errorlevel checks in reverse numeric order =
  186.                if errorlevel 3 goto three
  187.                if errorlevel 2 goto two
  188.                if errorlevel 1 goto one
  189.                goto quit
  190.                rem Action if user types abc
  191.                :one
  192.                echo one
  193.                goto quit
  194.                rem Action if user types def
  195.                :two
  196.                echo two
  197.                goto quit
  198.                rem Action if user types ghi
  199.                :three
  200.                echo three
  201.                goto quit
  202.                :quit
  203.  
  204.           Note that the error level checks are in decreasing numeric order.
  205.           This  is  required  due to the nature of the way DOS performs the
  206.           tests.
  207.  
  208.           ____ ________
  209.           File Detabber
  210.  
  211.                       magic
  212.                       magic
  213.           You can use magic to  remove  (expand)  tabs  from  a  file.  The
  214.           default tab expansion is 4 spaces. This default can be overridden
  215.           by setting an environment variable called TAB to your desired tab
  216.           expansion. You can also tack a number on to the end of the -detab
  217.           option on the command line, e.g.
  218.  
  219.                magic -detab3
  220.  
  221.           The  number  following  the  -detab  overrides  both  the program
  222.                   ___
  223.           default and your (optional) TAB environment variable.
  224.  
  225.           With no other command line arguments, input is expected  to  come
  226.           from  standard  input,  and  the  detabbed  output will go to the
  227.                                                          magic
  228.                                                          magic
  229.           standard output. Thus, a typical invocation of magic to  detab  a
  230.           file might be as follows:
  231.  
  232.                magic -detab < tabfile > notabs
  233.  
  234.           Or,  you  can  optionally supply an input file and output file on
  235.           the command line. If the output file name is not supplied, output
  236.           will go to the standard output device. Examples:
  237.  
  238.                magic -detab oldfile newfile
  239.                magic -detab3 oldfile
  240.  
  241.  
  242.           AUTHOR
  243.           AUTHOR
  244.           AUTHOR
  245.  
  246.  
  247.  
  248.                                                                       magic
  249.                                                                       magic
  250.                                    August 23, 1987                    magic
  251.  
  252.  
  253.  
  254.  
  255.           magic
  256.           magic
  257.           magic                  DNS C Documentation               Page -4-
  258.  
  259.  
  260.           Written and Copyright (C) 1987 by:
  261.  
  262.              Dwarf Nebula Software
  263.              PO Box 46, Dept. MG
  264.              SugarLand, TX 77487
  265.  
  266.           This program is in the public domain,  and  may  be  freely  dis-
  267.           tributed,  provided  it  is not sold (without permission from the
  268.           authors).
  269.  
  270.           We would appreciate any bug reports, as well as  any  suggestions
  271.           for improvement (new features, or upgrades to existing features).
  272.  
  273.  
  274.           SOURCE
  275.           SOURCE
  276.           SOURCE
  277.  
  278.                            magic
  279.                            magic
  280.           Source  code for magic may be purchased from the authors for $12.
  281.                       __ ___
  282.           Source code is not in the public domain. Source in either code or
  283.                              ________                  ____
  284.           object form is for personal use/modification only.
  285.  
  286.  
  287.           C FUNCTIONS
  288.           C FUNCTIONS
  289.           C FUNCTIONS
  290.  
  291.                     ____
  292.           We have a very interesting collection of C code for  IBM  PC  and
  293.           compatible  systems.  Drop  us  a  line, and let us send you some
  294.                            ____ ___
  295.           information. You will not be sorry. As a matter of fact,  it  may
  296.           be the most important letter you write this year.
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.                                                                       magic
  329.                                                                       magic
  330.                                    August 23, 1987                    magic
  331.  
  332.  
  333.